var vm = new Vue({
    //vue对象节点,指向父盒子
    el:'#addLost',                                                                   
    //vue实例 的data属性
    data:function(){
        return{
          
	      tableData:[],
	      lostEditorEdit:null,
	      lostTopic:{},
	      lostTopicRules:{ 
	    	  tname: [{ required: true, message: '请填写主题', trigger: 'blur' }],
	    	  item_type: [{ required: true, message: '请选择', trigger: 'blur' }],
	    	  lost_time: [{ required: true, message: '请选择', trigger: 'blur' }],
	    	  contact: [{ required: true, message: '请填写', trigger: 'blur' }],
	    	  contact_tel: [{ required: true, message: '请填写', trigger: 'blur' }],
	    	  contact_email: [{ required: true, message: '请填写', trigger: 'blur' }],
	    	  lost_address: [{ required: true, message: '请选择', trigger: 'blur' }]
	    	  //tcontent: [{ required: true, message: '请填写帖子内容', trigger: 'blur' }]
	      },
	      addressList:[],
	      typeList:[]
	   
        };
    },
    //vue实例 的methods
    methods:{
       submit:function(formName){
    	   vm.$refs[formName].validate(function(valid) {
 	          if (valid) {
	                  var url = './addTopic.action';
	                  var params = {
	                		"topic.plate.pid":2,
	                		"topic.tname":vm.lostTopic.tname,
	                  		"topic.item_type":vm.lostTopic.item_type,
	                  		"topic.lost_address":vm.lostTopic.lost_address,
	                  		"topic.lost_time":moment(vm.lostTopic.lost_time).format('YYYY-MM-DD'),
	                  		"topic.contact":vm.lostTopic.contact,
	                  		"topic.contact_tel":vm.lostTopic.contact_tel,
	                  		"topic.contact_email":vm.lostTopic.contact_email,
	                  		"topic.tcontent":vm.lostEditorEdit.getContent()
	                  };
	                  debugger
	                  pb.ajaxPost(url,params,function(r){
	                  	if(r.code == '000000'){
	                  		pb.alertSuc("发表成功");
	                  		window.top.location.href="index.jsp"; 
	                  	}else{
	                  		pb.alertErr("发表失败");
	                  	}
	                  	},function(err){

	                  		pb.alertErr("操作超时");
	                  	});
 	          } else {
 	            return false;
 	          }
    	  });
       },
       getEdit:function(){
    	   vm.lostEditorEdit = UM.getEditor("lostEditorEdit");
    	   $('.edui-container').css("width","");
    	   $('.edui-container').css("min-height","300px");
    	   $('.edui-body-container').css("width",""); 
    	  // $('.edui-body-container').css("min-height",""); 
       },
       getItems:function(){
    	   var url = "./getAllItem.action";
    	   var params = {  
    	   }
    	   pb.ajaxPost(url,params,function(r){
	       		if(r.code == '000000'){
	       			vm.typeList = r.itemTypes;
	       		}else{
	       		 pb.alertErr('获取信息失败');
	       		}
	       },function(err){
	    	   pb.alertErr('获取信息失败');
	       });
       },
       getPlaces:function(){
    	   var url = "./getAllPlace.action";
    	   var params = {  
    	   }
    	   pb.ajaxPost(url,params,function(r){
	       		if(r.code == '000000'){
	       			vm.addressList = r.places;
	       		}else{
	       		 pb.alertErr('获取信息失败');
	       		}
	       },function(err){
	    	   pb.alertErr('获取信息失败');
	       });
       }
    }
    //vue实例 的methods结束
});
vm.getEdit();
vm.getItems();
vm.getPlaces();